<!doctype html>



  


<html class="theme-next muse use-motion">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>



<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />












  
  
  <link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />




  
  
  
  

  
    
    
  

  

  

  
    
      
    

    
  

  

  
    
    
    <link href="//fonts.googleapis.com/css?family=Microsoft YaHei:300,300italic,400,400italic,700,700italic|consolas:300,300italic,400,400italic,700,700italic&subset=latin,latin-ext" rel="stylesheet" type="text/css">
  






<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.4.0" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=5.0.2" rel="stylesheet" type="text/css" />


  <meta name="keywords" content="PHP," />








  <link rel="shortcut icon" type="image/x-icon" href="http://ofy7k3v4s.bkt.clouddn.com/mylogo.png?v=5.0.2" />






<meta name="description" content="php&amp;#x57FA;&amp;#x7840;&amp;#x6587;&amp;#x4EF6;&amp;#x4EE5;.php&amp;#x540E;&amp;#x7F00;&amp;#x7ED3;&amp;#x5C3E;&amp;#xFF0C;&amp;#x6240;&amp;#x6709;&amp;#x7A0B;&amp;#x5E8F;&amp;#x5305;&amp;#x542B;&amp;#x5728; &amp;lt;?php ** &amp;#x8FD9;&amp;#x91CC;&amp;#x662F;&amp;#x4EE3;&amp;#x7801; **">
<meta property="og:type" content="article">
<meta property="og:title" content="PHP-基础">
<meta property="og:url" content="https://hongqinma.github.io/2015/03/22/24-PHP-基础/index.html">
<meta property="og:site_name" content="HongqinMa' Blog">
<meta property="og:description" content="php&amp;#x57FA;&amp;#x7840;&amp;#x6587;&amp;#x4EF6;&amp;#x4EE5;.php&amp;#x540E;&amp;#x7F00;&amp;#x7ED3;&amp;#x5C3E;&amp;#xFF0C;&amp;#x6240;&amp;#x6709;&amp;#x7A0B;&amp;#x5E8F;&amp;#x5305;&amp;#x542B;&amp;#x5728; &amp;lt;?php ** &amp;#x8FD9;&amp;#x91CC;&amp;#x662F;&amp;#x4EE3;&amp;#x7801; **">
<meta property="og:updated_time" content="2016-11-29T10:42:46.714Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="PHP-基础">
<meta name="twitter:description" content="php&amp;#x57FA;&amp;#x7840;&amp;#x6587;&amp;#x4EF6;&amp;#x4EE5;.php&amp;#x540E;&amp;#x7F00;&amp;#x7ED3;&amp;#x5C3E;&amp;#xFF0C;&amp;#x6240;&amp;#x6709;&amp;#x7A0B;&amp;#x5E8F;&amp;#x5305;&amp;#x542B;&amp;#x5728; &amp;lt;?php ** &amp;#x8FD9;&amp;#x91CC;&amp;#x662F;&amp;#x4EE3;&amp;#x7801; **">



<script type="text/javascript" id="hexo.configuration">
  var NexT = window.NexT || {};
  var CONFIG = {
    scheme: 'Muse',
    sidebar: {"position":"left","display":"post"},
    fancybox: true,
    motion: true,
    duoshuo: {
      userId: '6347850919329138000',
      author: 'Hiraku'
    }
  };
</script>




  <link rel="canonical" href="https://hongqinma.github.io/2015/03/22/24-PHP-基础/"/>


  <title> PHP-基础 | HongqinMa' Blog </title>
</head>

<body itemscope itemtype="//schema.org/WebPage" lang="en">

  



  <script type="text/javascript">
    var _hmt = _hmt || [];
    (function() {
      var hm = document.createElement("script");
      hm.src = "//hm.baidu.com/hm.js?10010323";
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(hm, s);
    })();
  </script>








  
  
    
  

  <div class="container one-collumn sidebar-position-left page-post-detail ">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="//schema.org/WPHeader">
      <div class="header-inner"><div class="site-meta custom-logo">
  
    <div class="site-meta-headline">
      <a>
        <img class="custom-logo-image" src="http://ofy7k3v4s.bkt.clouddn.com/photo.jpg"
             alt="HongqinMa' Blog"/>
      </a>
    </div>
  

  <div class="custom-logo-site-title">
    <a href="/"  class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <span class="site-title">HongqinMa' Blog</span>
      <span class="logo-line-after"><i></i></span>
    </a>
  </div>
  <p class="site-subtitle">Spell at all costs， to rush you in the future。</p>
</div>

<div class="site-nav-toggle">
  <button>
    <span class="btn-bar"></span>
    <span class="btn-bar"></span>
    <span class="btn-bar"></span>
  </button>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            Home
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/categories" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br />
            
            Categories
          </a>
        </li>
      
        
        <li class="menu-item menu-item-about">
          <a href="/about" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-user"></i> <br />
            
            About
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/archives" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br />
            
            Archives
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/tags" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br />
            
            Tags
          </a>
        </li>
      

      
    </ul>
  

  
</nav>

 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  
  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="//schema.org/Article">

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
            
            
              
                PHP-基础
              
            
          </h1>
        

        <div class="post-meta">
          <span class="post-time">
            <span class="post-meta-item-icon">
              <i class="fa fa-calendar-o"></i>
            </span>
            <span class="post-meta-item-text">Posted on</span>
            <time itemprop="dateCreated" datetime="2015-03-22T19:38:15+08:00" content="2015-03-22">
              2015-03-22
            </time>
          </span>

          
            <span class="post-category" >
              &nbsp; | &nbsp;
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">In</span>
              
                <span itemprop="about" itemscope itemtype="https://schema.org/Thing">
                  <a href="/categories/PHP/" itemprop="url" rel="index">
                    <span itemprop="name">PHP</span>
                  </a>
                </span>

                
                

              
            </span>
          

          
            
              <span class="post-comments-count">
                &nbsp; | &nbsp;
                <a href="/2015/03/22/24-PHP-基础/#comments" itemprop="discussionUrl">
                  <span class="post-comments-count ds-thread-count" data-thread-key="2015/03/22/24-PHP-基础/" itemprop="commentsCount"></span>
                </a>
              </span>
            
          

          

          

          
              &nbsp; | &nbsp;
              <span class="page-pv"><i class="fa fa-file-o"></i>
              <span class="busuanzi-value" id="busuanzi_value_page_pv" ></span>
              </span>
          

          
            <span id="busuanzi_container_page_pv">  <span id="busuanzi_value_page_pv"></span> Views</span>
          
        </div>
      </header>
    


    <div class="post-body" itemprop="articleBody">

      
      

      
        <h2 id="php&#x57FA;&#x7840;"><a href="#php&#x57FA;&#x7840;" class="headerlink" title="php&#x57FA;&#x7840;"></a>php&#x57FA;&#x7840;</h2><p>&#x6587;&#x4EF6;&#x4EE5;.php&#x540E;&#x7F00;&#x7ED3;&#x5C3E;&#xFF0C;&#x6240;&#x6709;&#x7A0B;&#x5E8F;&#x5305;&#x542B;&#x5728; <code>&lt;?php ** &#x8FD9;&#x91CC;&#x662F;&#x4EE3;&#x7801; ** ?&gt;</code>  </p>
<p>&#x907F;&#x514D;&#x4F7F;&#x7528;&#x4E2D;&#x6587;&#x76EE;&#x5F55;&#x548C;&#x4E2D;&#x6587;&#x6587;&#x4EF6;&#x540D;&#xFF0C;php&#x9875;&#x9762;&#x65E0;&#x6CD5;&#x76F4;&#x63A5;&#x6253;&#x5F00;&#x9700;&#x8981;&#x8FD0;&#x884C;&#x5728;&#x670D;&#x52A1;&#x5668;&#x73AF;&#x5883;&#x5F53;&#x4E2D;&#x3002;</p>
<h2 id="&#x914D;&#x7F6E;-php-&#x6587;&#x4EF6;&#xFF0C;&#x8BBF;&#x95EE;-https-&#x52A0;&#x5BC6;&#x7F51;&#x7AD9;"><a href="#&#x914D;&#x7F6E;-php-&#x6587;&#x4EF6;&#xFF0C;&#x8BBF;&#x95EE;-https-&#x52A0;&#x5BC6;&#x7F51;&#x7AD9;" class="headerlink" title="&#x914D;&#x7F6E; php &#x6587;&#x4EF6;&#xFF0C;&#x8BBF;&#x95EE; https &#x52A0;&#x5BC6;&#x7F51;&#x7AD9;"></a>&#x914D;&#x7F6E; php &#x6587;&#x4EF6;&#xFF0C;&#x8BBF;&#x95EE; https &#x52A0;&#x5BC6;&#x7F51;&#x7AD9;</h2><p>&#x5982;&#x4F55;&#x627E;&#x5230;&#x914D;&#x7F6E;&#x6587;&#x4EF6;&#xFF1A;</p>
<p>&#x5728;&#x540E;&#x7F00;&#x540D; .php &#x7684;&#x6587;&#x4EF6;&#x4E2D;&#x52A0;&#x4E0A;&#xFF1A;</p>
<ul>
<li>phpinfo();</li>
<li>exit;</li>
</ul>
<p>&#x6D4F;&#x89C8;&#x5668;&#x4E0B;&#x8BBF;&#x95EE;&#xFF1A;.php &#x540E;&#x7F00;&#x7684;&#x6587;&#x4EF6;</p>
<p>&#x627E;&#x5230;&#xFF1A;<code>Loaded Configuration File</code>&#x7684;&#x8DEF;&#x5F84;&#xFF0C;php.ini</p>
<p>&#x627E;&#x5230; <code>openssl</code>&#xFF0C;&#x628A; &#x2018;;&#x2019; &#x53BB;&#x6389;&#x5C31;&#x53EF;&#x4EE5;&#x8BBF;&#x95EE; <code>https</code></p>
<h2 id="&#x7B80;&#x5355;&#x7684;php&#x7A0B;&#x5E8F;"><a href="#&#x7B80;&#x5355;&#x7684;php&#x7A0B;&#x5E8F;" class="headerlink" title="&#x7B80;&#x5355;&#x7684;php&#x7A0B;&#x5E8F;"></a>&#x7B80;&#x5355;&#x7684;php&#x7A0B;&#x5E8F;</h2><figure class="highlight php"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div></pre></td><td class="code"><pre><div class="line"><span class="meta">&lt;?php</span></div><div class="line">  <span class="comment">// &#x7528;&#x6765;&#x6307;&#x5B9A;&#x7F16;&#x7801;&#x96C6;</span></div><div class="line">  header(<span class="string">&apos;Content-Type:text/html; charset=utf-8&apos;</span>);</div><div class="line">  <span class="comment">/*&#x8FD9;&#x662F;&#x4E00;&#x4E2A;&#x6700;&#x7B80;&#x5355;&#x7684;php&#x7A0B;&#x5E8F;*/</span></div><div class="line">  <span class="keyword">echo</span> <span class="string">&apos;hello world!&apos;</span>;</div><div class="line"><span class="meta">?&gt;</span></div></pre></td></tr></table></figure>
<p>JSONP &#x539F;&#x7406;&#xFF1A;&#x6D4F;&#x89C8;&#x5668;&#x7684; <code>XMLHTTPRequest</code> &#x6709;&#x57DF;&#x7684;&#x9650;&#x5236;&#xFF0C;<code>img</code> &#x7684; <code>src</code>&#xFF0C;<code>link</code> &#x7684; <code>href</code> &#x548C; <code>script</code> &#x7684; <code>src</code> &#x6CA1;&#x6709;&#x57DF;&#x7684;&#x9650;&#x5236;&#xFF0C;&#x6D4F;&#x89C8;&#x5668;&#x7684;&#x5B89;&#x5168;&#x673A;&#x5236;&#x3002;</p>
<p>&#x5728;&#x4F20;&#x7EDF;&#x91CC;&#x6CA1;&#x6709;&#x6807;&#x51C6;&#x7684;&#x6280;&#x672F;&#xFF0C;&#x5229;&#x7528;&#x4E86;&#x6280;&#x672F;&#x4E0A;&#x7684;&#x7279;&#x6027;&#x7ED5;&#x8FC7;&#x4E86;&#x5B89;&#x5168;&#x6027;&#x7684;&#x9650;&#x5236;&#xFF0C;&#x5C31;&#x5DE7;&#x5999;&#x7684;&#x4F7F;&#x7528; <code>script</code> &#xFF0C;&#x5C31;&#x4F1A;&#x5F97;&#x5230;&#x8BF7;&#x6C42;&#x8D44;&#x6E90;&#x8FD4;&#x56DE;&#x7684;&#x5185;&#x5BB9;&#x3002;</p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line"><span class="tag">&lt;<span class="name">script</span> <span class="attr">src</span>=<span class="string">&quot;xx.php?callback=fn&quot;</span>&gt;</span><span class="undefined"></span><span class="tag">&lt;/<span class="name">script</span>&gt;</span></div><div class="line"><span class="comment">&lt;!-- &#x76F8;&#x5F53;&#x4E8E;&#x8FD4;&#x56DE;&#x4E86; fn()&#xFF0C;&#x53D8;&#x5411;&#x7684;&#x5B9E;&#x73B0;&#x4E86;&#x8DE8;&#x57DF; --&gt;</span></div></pre></td></tr></table></figure>
<p>JSONP &#x7A81;&#x7834;&#x4E86;&#x57DF;&#x7684;&#x9650;&#x5236;&#xFF0C;&#x6CA1;&#x6709;&#x7A81;&#x7834;&#x5B89;&#x5168;&#x9650;&#x5236;&#x3002;&#x4E0D;&#x80FD;&#x5B9E;&#x73B0; post &#x8DE8;&#x57DF;&#x3002;&#x8DE8;&#x57DF; JSONP &#x662F;&#x4E3B;&#x6D41;&#x3002;</p>
<h2 id="&#x53D8;&#x91CF;"><a href="#&#x53D8;&#x91CF;" class="headerlink" title="&#x53D8;&#x91CF;"></a>&#x53D8;&#x91CF;</h2><ol>
<li>&#x53D8;&#x91CF;&#x4EE5;$&#x5F00;&#x5934; &#x5B57;&#x6BCD;/&#x6570;&#x5B57;/&#x4E0B;&#x5212;&#x7EBF; &#x4E0D;&#x80FD;&#x4EE5;&#x6570;&#x5B57;&#x5F00;&#x5934;  </li>
<li>&#x5927;&#x5C0F;&#x5199;&#x654F;&#x611F;&#xFF08;&#x533A;&#x5206;&#x5927;&#x5C0F;&#x5199;&#xFF09;</li>
</ol>
<p>(1)&#x3001;&#x58F0;&#x660E;&#x4E00;&#x4E2A;&#x53D8;&#x91CF;$a&#x5E76;&#x8D4B;&#x503C;&#x4E3A;10</p>
<figure class="highlight php"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">$a = <span class="number">10</span>;</div></pre></td></tr></table></figure>
<p>(2)&#x3001;&#x8F93;&#x51FA;&#x4E00;&#x4E2A;&#x53D8;&#x91CF;$a</p>
<figure class="highlight php"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line"><span class="keyword">echo</span> $a;</div></pre></td></tr></table></figure>
<p>(3)&#x3001;&#x58F0;&#x660E;&#x4E00;&#x4E2A;&#x53D8;&#x91CF;$b&#x5E76;&#x8D4B;&#x503C;&#x4E3A;10</p>
<figure class="highlight php"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">$b = <span class="number">10</span>;</div></pre></td></tr></table></figure>
<p>(4)&#x3001;&#x8F93;&#x51FA;&#x4E00;&#x4E2A;&#x53D8;&#x91CF;$b</p>
<figure class="highlight php"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line"><span class="keyword">echo</span> $b;</div></pre></td></tr></table></figure>
<p>&#x8F93;&#x51FA;&#x987A;&#x5E8F;&#x662F;&#x81EA;&#x4E0A;&#x5411;&#x4E0B;&#x7684;&#xFF0C;&#x76F8;&#x5F53;&#x4E8E; js <code>dcoument.write()</code> &#x3002;</p>
<h2 id="&#x6570;&#x636E;&#x7C7B;&#x578B;"><a href="#&#x6570;&#x636E;&#x7C7B;&#x578B;" class="headerlink" title="&#x6570;&#x636E;&#x7C7B;&#x578B;"></a>&#x6570;&#x636E;&#x7C7B;&#x578B;</h2><p><strong>&#x5B57;&#x7B26;&#x578B;</strong>  </p>
<figure class="highlight php"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">$str = <span class="string">&apos;hello world!&apos;</span>;</div></pre></td></tr></table></figure>
<p><strong>&#x6574;&#x578B;</strong>  </p>
<figure class="highlight php"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">$num = <span class="number">10</span>;</div></pre></td></tr></table></figure>
<p><strong>&#x6D6E;&#x70B9;&#x578B;</strong>  </p>
<figure class="highlight php"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">$float = <span class="number">10.5</span>;</div></pre></td></tr></table></figure>
<p><strong>&#x5E03;&#x5C14;&#x578B;</strong>  </p>
<figure class="highlight php"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">$bool = <span class="keyword">true</span>;</div></pre></td></tr></table></figure>
<p><strong>&#x6570;&#x7EC4;</strong></p>
<p>JavaScript &#x6570;&#x7EC4;&#x5B9A;&#x4E49;&#x65B9;&#x5F0F; <code>var arr = [1, 2, 3]</code>&#x3002;arr[0]&#x3001;arr[1]&#x3001;arr[1] &#x7B49;&#xFF1B;</p>
<blockquote>
<p>PHP &#x662F;&#x8FD9;&#x6837;&#x5B9A;&#x4E49;&#x6570;&#x7EC4;&#x7684;</p>
</blockquote>
<figure class="highlight php"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div></pre></td><td class="code"><pre><div class="line">$arr = <span class="keyword">array</span>(<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>);  <span class="comment">// &#x8FD9;&#x79CD;&#x65B9;&#x5F0F;&#x53EB;&#x505A;**&#x7D22;&#x5F15;&#x6570;&#x7EC4;**</span></div><div class="line"><span class="comment">// echo $arr[0];</span></div><div class="line"><span class="comment">// echo $arr[2];</span></div><div class="line"><span class="comment">// &#x5B9A;&#x4E49;&#x65B9;&#x5F0F;&#x548C;Javascript&#x6709;&#x533A;&#x522B;&#xFF0C;&#x4F46;&#x662F;&#x8BBF;&#x95EE;&#x65B9;&#x5F0F;&#x662F;&#x4E00;&#x6837;&#x7684;</span></div><div class="line"><span class="comment">// var obj = {name: Hiraku, age: 10}</span></div><div class="line"><span class="comment">// PHP&#x53E6;&#x4E00;&#x79CD;&#x5B9A;&#x5B9A;&#x6570;&#x7EC4;&#x7684;&#x65B9;&#x5F0F;&#xFF0C;&#x6240;&#x8868;&#x8FBE;&#x7684;&#x610F;&#x4E49;&#x548C;Javascript&#x4E00;&#x6837;&#xFF0C;</span></div><div class="line"><span class="comment">// &#x53EA;&#x662F;&#x8BED;&#x6CD5;&#x683C;&#x5F0F;&#x4E0D;&#x4E00;&#x6837;</span></div><div class="line"><span class="comment">// &#x8FD9;&#x79CD;&#x65B9;&#x5F0F;&#x53EB;&#x505A;**&#x5173;&#x8054;&#x6570;&#x7EC4;**</span></div><div class="line">$arr1 = <span class="keyword">array</span>(<span class="string">&apos;name&apos;</span>=&gt;<span class="string">&apos;Hiraku&apos;</span>, <span class="string">&apos;age&apos;</span>=&gt;<span class="number">10</span>);</div><div class="line"><span class="comment">// echo $arr1[&apos;name&apos;];</span></div></pre></td></tr></table></figure>
<p><strong>&#x5BF9;&#x8C61;</strong> </p>
<figure class="highlight php"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div></pre></td><td class="code"><pre><div class="line"><span class="comment">// Javascript var obj = {name: Hirkau, age: 10}</span></div><div class="line"><span class="comment">// PHP&#x9700;&#x8981;&#x5148;&#x521B;&#x5EFA;&#x4E00;&#x4E2A;&#x7C7B;&#xFF0C;&#x4E0B;&#x9762;&#x5C31;&#x662F;&#x521B;&#x5EFA;&#x8FC7;&#x7A0B;</span></div><div class="line"><span class="class"><span class="keyword">class</span> <span class="title">Person</span> </span>{</div><div class="line">    <span class="keyword">public</span> $name = <span class="string">&apos;Hiraku&apos;</span>;</div><div class="line">    <span class="keyword">public</span> $age = <span class="number">10</span>;</div><div class="line">}</div><div class="line">$person = <span class="keyword">new</span> Person;</div><div class="line"><span class="comment">// PHP&#x8BBF;&#x95EE;&#x4E00;&#x4E2A;&#x5BF9;&#x8C61;&#x5C5E;&#x6027;&#x7684;&#x8BED;&#x6CD5;&#x662F;&#x4E0D;&#x4E00;&#x6837;&#x7684;</span></div><div class="line"><span class="keyword">echo</span> $person-&gt;name;</div><div class="line"><span class="comment">// obj[&apos;name&apos;]; obj.name &#x4E0D;&#x884C;</span></div></pre></td></tr></table></figure>
<p><strong>NULL</strong>  </p>
<blockquote>
<p>PHP &#x4E2D;&#x4E00;&#x79CD;&#x7279;&#x6B8A;&#x7684;&#x6570;&#x636E;&#x7C7B;&#x578B;&#xFF0C;&#x8868;&#x793A;&#x7A7A;&#x503C;&#xFF0C;&#x5373;&#x8868;&#x793A;&#x6CA1;&#x6709;&#x4E3A;&#x8BE5;&#x53D8;&#x91CF;&#x8BBE;&#x7F6E;&#x4EFB;&#x4F55;&#x503C; <code>null</code> (&#x7A7A;&#x503C;)&#x4E0D;&#x533A;&#x5206;&#x5927;&#x5C0F;&#x5199;&#xFF0C;<code>null</code> &#x548C; <code>NULL</code> &#x662F;&#x4E00;&#x6837;&#x7684;&#x3002;</p>
</blockquote>
<p><strong>&#x5355;&#x5F15;&#x53F7;&amp;&#x53CC;&#x5F15;&#x53F7;&#x533A;&#x522B;&#xFF1A;</strong></p>
<blockquote>
<p>&#x5355;&#x5F15;&#x53F7;&#x5185;&#x90E8;&#x7684;&#x53D8;&#x91CF;&#x4E0D;&#x4F1A;&#x6267;&#x884C;&#x53CC;&#x5F15;&#x53F7;&#x4F1A;&#x6267;&#x884C;</p>
</blockquote>
<figure class="highlight php"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div></pre></td><td class="code"><pre><div class="line">$name = <span class="string">&apos;&#x5C0F;&#x660E;&apos;</span>;</div><div class="line"><span class="keyword">echo</span> <span class="string">&apos;name is $name&apos;</span>; <span class="comment">//&#x8F93;&#x51FA; name is $name</span></div><div class="line"><span class="keyword">echo</span> <span class="string">&apos;&lt;br&gt;&apos;</span>;</div><div class="line"><span class="keyword">echo</span> <span class="string">&quot;name is $name&quot;</span>; <span class="comment">//&#x8F93;&#x51FA; name is &#x5C0F;&#x660E;</span></div></pre></td></tr></table></figure>
<p>&#x7D22;&#x5F15;&#x6570;&#x7EC4;&#x3001;&#x5173;&#x8054;&#x6570;&#x7EC4;</p>
<h2 id="&#x8FD0;&#x7B97;&#x7B26;-amp-&#x5185;&#x5BB9;&#x8F93;&#x51FA;"><a href="#&#x8FD0;&#x7B97;&#x7B26;-amp-&#x5185;&#x5BB9;&#x8F93;&#x51FA;" class="headerlink" title="&#x8FD0;&#x7B97;&#x7B26;&amp;&#x5185;&#x5BB9;&#x8F93;&#x51FA;"></a>&#x8FD0;&#x7B97;&#x7B26;&amp;&#x5185;&#x5BB9;&#x8F93;&#x51FA;</h2><h3 id="&#x8FD0;&#x7B97;&#x7B26;"><a href="#&#x8FD0;&#x7B97;&#x7B26;" class="headerlink" title="&#x8FD0;&#x7B97;&#x7B26;"></a>&#x8FD0;&#x7B97;&#x7B26;</h3><p>&#x57FA;&#x672C;&#x4E0E;Javascript&#x8BED;&#x6CD5;&#x4E00;&#x81F4;&#xFF0C;<code>.</code> &#x53F7;&#x8868;&#x793A;&#x5B57;&#x7B26;&#x4E32;&#x62FC;&#x63A5;&#x7B26;&#xFF0C;JavaScript&#x4E2D;&#x4E3A; <code>+</code> &#x53F7;</p>
<h3 id="&#x5185;&#x5BB9;&#x8F93;&#x51FA;"><a href="#&#x5185;&#x5BB9;&#x8F93;&#x51FA;" class="headerlink" title="&#x5185;&#x5BB9;&#x8F93;&#x51FA;"></a>&#x5185;&#x5BB9;&#x8F93;&#x51FA;</h3><ul>
<li>echo&#xFF1A;&#x8F93;&#x51FA;&#x7B80;&#x5355;&#x6570;&#x636E;&#x7C7B;&#x578B;&#xFF0C;&#x5982;&#x5B57;&#x7B26;&#x4E32;&#x3001;&#x6570;&#x503C;</li>
<li>print_r()&#xFF1A;&#x8F93;&#x51FA;&#x590D;&#x6742;&#x6570;&#x636E;&#x7C7B;&#x578B;&#xFF0C;&#x5982;&#x6570;&#x7EC4;</li>
<li>var_dump()&#xFF1A;&#x8F93;&#x51FA;&#x8BE6;&#x7EC6;&#x4FE1;&#x606F;&#xFF0C;&#x5982;&#x5BF9;&#x8C61;&#x3001;&#x6570;&#x7EC4;&#xFF08;&#x4E86;&#x89E3;&#xFF09;</li>
</ul>
<h2 id="&#x51FD;&#x6570;"><a href="#&#x51FD;&#x6570;" class="headerlink" title="&#x51FD;&#x6570;"></a>&#x51FD;&#x6570;</h2><figure class="highlight php"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div></pre></td><td class="code"><pre><div class="line"><span class="comment">//&#x51FD;&#x6570;&#x540D;&#x5BF9;&#x5927;&#x5C0F;&#x5199;&#x4E0D;&#x654F;&#x611F;  &#x9ED8;&#x8BA4;&#x53C2;&#x6570;&#xFF08;&#x4E86;&#x89E3;&#x5373;&#x53EF;&#xFF09;</span></div><div class="line"><span class="function"><span class="keyword">function</span> <span class="title">sayHello</span><span class="params">($name=<span class="string">&apos;web developer&apos;</span>)</span> </span>{</div><div class="line">  <span class="keyword">echo</span> $name . <span class="string">&apos;&#x4F60;&#x597D;!&apos;</span>;</div><div class="line">}</div><div class="line">sayHello();</div></pre></td></tr></table></figure>
<h2 id="&#x5206;&#x652F;&#xFF0C;&#x5FAA;&#x73AF;&#x8BED;&#x53E5;"><a href="#&#x5206;&#x652F;&#xFF0C;&#x5FAA;&#x73AF;&#x8BED;&#x53E5;" class="headerlink" title="&#x5206;&#x652F;&#xFF0C;&#x5FAA;&#x73AF;&#x8BED;&#x53E5;"></a>&#x5206;&#x652F;&#xFF0C;&#x5FAA;&#x73AF;&#x8BED;&#x53E5;</h2><figure class="highlight php"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div></pre></td><td class="code"><pre><div class="line"><span class="comment">/**</span></div><div class="line"> * &#x5206;&#x652F;&#x63A7;&#x5236;&#x8BED;&#x53E5;&#x3001;&#x5FAA;&#x73AF;&#x8BED;&#x53E5; &#x4E0E;Javascript&#x4E00;&#x6837;</div><div class="line"> * foreach &#x6570;&#x7EC4;&#x904D;&#x5386;&#x51FD;&#x6570;&#xFF0C;&#x7C7B;&#x4F3C;Javascript&#x4E2D;&#x7684; for in</div><div class="line"> */</div><div class="line">$name = <span class="string">&apos;Hiraku&apos;</span>;</div><div class="line"><span class="keyword">if</span>($name == <span class="string">&apos;Hiraku&apos;</span>) {</div><div class="line">   <span class="keyword">echo</span> <span class="string">&apos;&#x6211;&#x5DF2;&#x7ECF;&#x5728;&apos;</span> . $name . <span class="string">&apos;&#x5B66;&#x4E60;&apos;</span>;</div><div class="line">} <span class="keyword">else</span> {</div><div class="line">   <span class="keyword">echo</span> <span class="string">&apos;&#x6211;&#x8FD8;&#x6CA1;&#x6709;&#x5B66;&#x4E60;&#x8FC7;&#x7F16;&#x7A0B;&apos;</span>;</div><div class="line">}</div><div class="line">$arr = <span class="keyword">array</span>(<span class="string">&apos;Hiraku&apos;</span>, <span class="string">&apos;&#x4ECA;&#x5E74;&apos;</span>, <span class="string">&apos;10&#x5C81;&#x4E86;&apos;</span>);<span class="comment">// &#x7D22;&#x5F15;&#x6570;&#x7EC4;  </span></div><div class="line">$length = count($arr);<span class="comment">// PHP&#x51FD;&#x6570;&#xFF0C;&#x8BA1;&#x7B97;&#x6570;&#x7EC4;&#x7684;&#x957F;&#x5EA6;</span></div><div class="line"><span class="keyword">for</span>($i=<span class="number">0</span>; $i&lt;$length; $i++) { <span class="comment">// &#x548C;Javascript&#x662F;&#x4E00;&#x6837;&#x7684;</span></div><div class="line">  <span class="keyword">echo</span> $arr[$i];</div><div class="line">}</div><div class="line"><span class="keyword">foreach</span>($arr <span class="keyword">as</span> $k=&gt;$v) {</div><div class="line">    <span class="keyword">echo</span> $k . <span class="string">&apos;~~~&apos;</span> . $v;</div><div class="line">};</div><div class="line">$arr1 = <span class="keyword">array</span>(<span class="string">&apos;name&apos;</span>=&gt;<span class="string">&apos;Hiraku&apos;</span>, <span class="string">&apos;age&apos;</span>=&gt;<span class="string">&apos;10&apos;</span>);<span class="comment">// &#x5173;&#x8054;&#x6570;&#x7EC4;</span></div><div class="line"><span class="keyword">echo</span> $arr1[<span class="number">0</span>];<span class="comment">// &#x9A8C;&#x8BC1;&#x5173;&#x8054;&#x6570;&#x7EC4;&#x4E0D;&#x53EF;&#x4EE5;&#x6309;&#x7D22;&#x5F15;&#x4E0B;&#x6807;&#x6765;&#x8BBF;&#x95EE;</span></div><div class="line"><span class="keyword">foreach</span>($arr1 <span class="keyword">as</span> $key=&gt;$val) {<span class="comment">//PHP&#x904D;&#x5386;&#x4E00;&#x4E2A;&#x5173;&#x8054;&#x6570;&#x7EC4;</span></div><div class="line">   <span class="keyword">echo</span> $key . <span class="string">&apos;~~~&apos;</span> . $val;</div><div class="line">}<span class="comment">// &#x5B9E;&#x9645;&#x5F00;&#x53D1;&#x90FD;&#x662F;&#x7528;foreach&#x6765;&#x904D;&#x5386;&#x6570;&#x7EC4;&#x7684;</span></div></pre></td></tr></table></figure>
<h2 id="&#x8868;&#x5355;&#x5904;&#x7406;"><a href="#&#x8868;&#x5355;&#x5904;&#x7406;" class="headerlink" title="&#x8868;&#x5355;&#x5904;&#x7406;"></a>&#x8868;&#x5355;&#x5904;&#x7406;</h2><ol>
<li>&#x8868;&#x5355; <code>name</code> &#x5C5E;&#x6027;&#x7684;&#x662F;&#x7528;&#x6765;&#x63D0;&#x4F9B;&#x7ED9;&#x670D;&#x52A1;&#x7AEF;&#x63A5;&#x6536;&#x6240;&#x4F20;&#x9012;&#x6570;&#x636E;&#x800C;&#x8BBE;&#x7F6E;&#x7684;</li>
<li>&#x8868;&#x5355; <code>action</code> &#x5C5E;&#x6027;&#x8BBE;&#x7F6E;&#x63A5;&#x6536;&#x6570;&#x636E;&#x7684;&#x5904;&#x7406;&#x7A0B;&#x5E8F; </li>
<li>&#x8868;&#x5355; <code>method</code> &#x5C5E;&#x6027;&#x8BBE;&#x7F6E;&#x53D1;&#x9001;&#x6570;&#x636E;&#x7684;&#x65B9;&#x5F0F; </li>
<li>&#x5F53;&#x4E0A;&#x4F20;&#x6587;&#x4EF6;&#x662F;&#x9700;&#x8981;&#x8BBE;&#x7F6E; <code>enctype=&quot;multipart/form-data&quot;</code>&#xFF0C;&#x4E14;&#x53EA;&#x80FD; <code>post</code> &#x65B9;&#x5F0F;!!!!</li>
<li><code>$_GET</code>&#x63A5;&#x6536; <code>get</code> &#x4F20;&#x503C;</li>
<li><code>$_POST</code>&#x63A5;&#x6536; <code>post</code> &#x4F20;&#x503C;</li>
<li><code>$_FILES</code> &#x63A5;&#x6536;&#x6587;&#x4EF6;&#x4E0A;&#x4F20;  </li>
</ol>
<h2 id="&#x6587;&#x4EF6;&#x5BFC;&#x5165;-amp-amp-&#x5E38;&#x7528;php&#x51FD;&#x6570;"><a href="#&#x6587;&#x4EF6;&#x5BFC;&#x5165;-amp-amp-&#x5E38;&#x7528;php&#x51FD;&#x6570;" class="headerlink" title="&#x6587;&#x4EF6;&#x5BFC;&#x5165;&amp;&amp;&#x5E38;&#x7528;php&#x51FD;&#x6570;"></a>&#x6587;&#x4EF6;&#x5BFC;&#x5165;&amp;&amp;&#x5E38;&#x7528;php&#x51FD;&#x6570;</h2><figure class="highlight php"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line"><span class="keyword">include</span> <span class="string">&apos;07.form.html&apos;</span>; <span class="comment">// &#x7B2C;&#x4E00;&#x79CD;&#x65B9;&#x6CD5;</span></div><div class="line"><span class="keyword">require</span> <span class="string">&apos;07.form.php&apos;</span>; <span class="comment">// &#x7B2C;&#x4E8C;&#x79CD;&#x65B9;&#x6CD5;</span></div></pre></td></tr></table></figure>
<figure class="highlight php"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div></pre></td><td class="code"><pre><div class="line">$array = <span class="keyword">array</span>(</div><div class="line">    <span class="string">&apos;username&apos;</span>=&gt;<span class="string">&apos;Hirkau&apos;</span>,</div><div class="line">    <span class="string">&apos;password&apos;</span>=&gt;<span class="string">&apos;123456&apos;</span></div><div class="line">);</div><div class="line"><span class="keyword">echo</span> <span class="string">&apos;&#x83B7;&#x53D6;&#x6570;&#x7EC4;&#x7684;&#x957F;&#x5EA6;&#xFF1A;&apos;</span>.count($array);</div><div class="line"><span class="keyword">echo</span> <span class="string">&apos;&lt;br&gt;&apos;</span>;</div><div class="line"><span class="keyword">echo</span> <span class="string">&apos;&#x5224;&#x65AD;&#x662F;&#x5426;&#x5728;&#x6570;&#x7EC4;&#x4E2D;&#xFF1A;&apos;</span>.in_array(<span class="string">&apos;Hirkau&apos;</span>,$array);</div><div class="line"><span class="keyword">echo</span> <span class="string">&apos;&lt;br&gt;&apos;</span>;</div><div class="line"><span class="keyword">echo</span> <span class="string">&apos;&#x68C0;&#x6D4B;&#x6570;&#x7EC4;&#x4E2D;&#x662F;&#x5426;&#x5B58;&#x5728;key&#xFF1A;&apos;</span>.array_key_exists(<span class="string">&apos;username&apos;</span>,$array);</div><div class="line"><span class="keyword">echo</span> <span class="string">&apos;&lt;br&gt;&apos;</span>;</div></pre></td></tr></table></figure>
<h2 id="&#x6570;&#x636E;&#x63CF;&#x8FF0;&#x548C;&#x4F8B;&#x5B50;"><a href="#&#x6570;&#x636E;&#x63CF;&#x8FF0;&#x548C;&#x4F8B;&#x5B50;" class="headerlink" title="&#x6570;&#x636E;&#x63CF;&#x8FF0;&#x548C;&#x4F8B;&#x5B50;"></a>&#x6570;&#x636E;&#x63CF;&#x8FF0;&#x548C;&#x4F8B;&#x5B50;</h2><ul>
<li>&#x5FC5;&#x987B;&#x6709;&#x4E00;&#x4E2A;&#x6839;&#x5143;&#x7D20;</li>
<li>&#x4E0D;&#x53EF;&#x6709;&#x7A7A;&#x683C;&#x3001;&#x4E0D;&#x53EF;&#x4EE5;&#x6570;&#x5B57;&#x6216;.&#x5F00;&#x5934;&#x3001;&#x5927;&#x5C0F;&#x5199;&#x654F;&#x611F;  </li>
<li>&#x4E0D;&#x53EF;&#x4EA4;&#x53C9;&#x5D4C;&#x5957;  </li>
<li>&#x5C5E;&#x6027;&#x53CC;&#x5F15;&#x53F7;&#xFF08;&#x6D4F;&#x89C8;&#x5668;&#x81EA;&#x52A8;&#x4FEE;&#x6B63;&#x6210;&#x53CC;&#x5F15;&#x53F7;&#x4E86;&#xFF09;</li>
<li>&#x6CE8;&#x91CA;&#x548C;HTML&#x4E00;&#x6837;  </li>
</ul>
<p>&#x867D;&#x7136;&#x53EF;&#x4EE5;&#x63CF;&#x8FF0;&#x548C;&#x4F20;&#x8F93;&#x590D;&#x6742;&#x6570;&#x636E;&#xFF0C;&#x4F46;&#x662F;&#x5176;&#x89E3;&#x6790;&#x8FC7;&#x4E8E;&#x590D;&#x6742;&#x5E76;&#x4E14;&#x4F53;&#x79EF;&#x8F83;&#x5927;&#xFF0C;&#x6240;&#x4EE5;&#x5B9E;&#x73B0;&#x5F00;&#x53D1;&#x5DF2;&#x7ECF;&#x5F88;&#x5C11;&#x4F7F;&#x7528;&#x4E86;&#x3002;</p>
<h3 id="xml-&#x6587;&#x4EF6;"><a href="#xml-&#x6587;&#x4EF6;" class="headerlink" title="xml &#x6587;&#x4EF6;"></a>xml &#x6587;&#x4EF6;</h3><figure class="highlight xml"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div></pre></td><td class="code"><pre><div class="line"><span class="php"><span class="meta">&lt;?</span>xml version=<span class="string">&quot;1.0&quot;</span> encoding=<span class="string">&quot;UTF-8&quot;</span><span class="meta">?&gt;</span></span></div><div class="line"><span class="tag">&lt;<span class="name">root</span>&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">arrayList</span>&gt;</span></div><div class="line">        <span class="tag">&lt;<span class="name">array</span>&gt;</span></div><div class="line">            <span class="tag">&lt;<span class="name">src</span>&gt;</span>images/banner.jpg<span class="tag">&lt;/<span class="name">src</span>&gt;</span></div><div class="line">            <span class="tag">&lt;<span class="name">newPirce</span>&gt;</span>12.00<span class="tag">&lt;/<span class="name">newPirce</span>&gt;</span></div><div class="line">            <span class="tag">&lt;<span class="name">oldPrice</span>&gt;</span>30.00<span class="tag">&lt;/<span class="name">oldPrice</span>&gt;</span></div><div class="line">        <span class="tag">&lt;/<span class="name">array</span>&gt;</span></div><div class="line">        <span class="tag">&lt;<span class="name">array</span>&gt;</span></div><div class="line">            <span class="tag">&lt;<span class="name">src</span>&gt;</span>images/banner.jpg<span class="tag">&lt;/<span class="name">src</span>&gt;</span></div><div class="line">            <span class="tag">&lt;<span class="name">newPirce</span>&gt;</span>12.00<span class="tag">&lt;/<span class="name">newPirce</span>&gt;</span></div><div class="line">            <span class="tag">&lt;<span class="name">oldPrice</span>&gt;</span>30.00<span class="tag">&lt;/<span class="name">oldPrice</span>&gt;</span></div><div class="line">        <span class="tag">&lt;/<span class="name">array</span>&gt;</span></div><div class="line">    <span class="tag">&lt;/<span class="name">arrayList</span>&gt;</span></div><div class="line"><span class="tag">&lt;/<span class="name">root</span>&gt;</span></div></pre></td></tr></table></figure>
<h3 id="php-&#x6587;&#x4EF6;"><a href="#php-&#x6587;&#x4EF6;" class="headerlink" title="php &#x6587;&#x4EF6;"></a>php &#x6587;&#x4EF6;</h3><figure class="highlight php"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div></pre></td><td class="code"><pre><div class="line"><span class="meta">&lt;?php</span> </div><div class="line">    header(<span class="string">&apos;Content-Type:text/xml;charset=utf-8&apos;</span>);</div><div class="line">    <span class="comment">/*&#x4EE5;xml&#x683C;&#x5F0F;&#x4F20;&#x8F93;&#x6570;&#x636E;&#x7684;&#x65F6;&#x5019;&#x8981;&#x6C42;&#x54CD;&#x5E94;&#x5185;&#x5BB9;&#x683C;&#x5F0F;&#x662F;   text/xml*/</span></div><div class="line">    <span class="comment">/*file_get_contents &#x83B7;&#x53D6;&#x6587;&#x4EF6;&#x5185;&#x5BB9;*/</span></div><div class="line">    $xml = file_get_contents(<span class="string">&apos;01.xml&apos;</span>);</div><div class="line">    <span class="comment">/*&#x8F93;&#x51FA;xml&#x5185;&#x5BB9;*/</span></div><div class="line">    <span class="keyword">echo</span> $xml;</div><div class="line"><span class="meta">?&gt;</span></div></pre></td></tr></table></figure>
<p>ajax &#x8BF7;&#x6C42;</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div></pre></td><td class="code"><pre><div class="line"><span class="keyword">var</span> xhr = <span class="keyword">new</span> XMLHttpRequest;</div><div class="line">xhr.open(<span class="string">&apos;get&apos;</span>,<span class="string">&apos;01.php&apos;</span>);</div><div class="line">xhr.send(<span class="literal">null</span>);</div><div class="line">xhr.onreadystatechange = <span class="function"><span class="keyword">function</span>(<span class="params"></span>)</span>{</div><div class="line">    <span class="keyword">if</span>(xhr.status == <span class="number">200</span> &amp;&amp; xhr.readyState == <span class="number">4</span>){</div><div class="line">        <span class="comment">/*&#x83B7;&#x53D6;&#x5230;XML&#x683C;&#x5F0F;&#x5185;&#x5BB9;  &#x653E;&#x56DE;&#x7684;&#x662F;DOM&#x5BF9;&#x8C61;  document*/</span></div><div class="line">        <span class="keyword">var</span> xml = xhr.responseXML;</div><div class="line">        <span class="comment">/*&#x901A;&#x8FC7;&#x9009;&#x7740;&#x5668;&#x53EF;&#x4EE5;&#x83B7;&#x53D6;&#x5230;xml&#x7684;&#x6570;&#x636E;*/</span></div><div class="line">        <span class="built_in">console</span>.log(xml.querySelectorAll(<span class="string">&apos;array&apos;</span>)[<span class="number">0</span>].querySelector(<span class="string">&apos;src&apos;</span>).innerHTML);</div><div class="line">    }</div><div class="line">}</div></pre></td></tr></table></figure>
<h3 id="JSON"><a href="#JSON" class="headerlink" title="JSON"></a>JSON</h3><p>&#x5373;JavaScript Object Notation&#xFF0C;&#x53E6;&#x4E00;&#x79CD;&#x8F7B;&#x91CF;&#x7EA7;&#x7684;&#x6587;&#x672C;&#x6570;&#x636E;&#x4EA4;&#x6362;&#x683C;&#x5F0F;&#xFF0C;&#x72EC;&#x7ACB;&#x4E8E;&#x8BED;&#x8A00;&#x3002;</p>
<ul>
<li>&#x6570;&#x636E;&#x5728;&#x540D;&#x79F0;/&#x503C;&#x5BF9;&#x4E2D; </li>
<li>&#x6570;&#x636E;&#x7531;&#x9017;&#x53F7;&#x5206;&#x9694;(&#x6700;&#x540E;&#x4E00;&#x4E2A;&#x5065;/&#x503C;&#x5BF9;&#x4E0D;&#x80FD;&#x5E26;&#x9017;&#x53F7;) </li>
<li>&#x82B1;&#x62EC;&#x53F7;&#x4FDD;&#x5B58;&#x5BF9;&#x8C61;&#x65B9;&#x62EC;&#x53F7;&#x4FDD;&#x5B58;&#x6570;&#x7EC4;  </li>
<li>&#x4F7F;&#x7528;&#x53CC;&#x5F15;&#x53F7;  </li>
</ul>
<figure class="highlight json"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div></pre></td><td class="code"><pre><div class="line">[</div><div class="line">  {<span class="attr">&quot;src&quot;</span>:<span class="string">&quot;images/detail01.jpg&quot;</span>,<span class="attr">&quot;oldPrice&quot;</span>:<span class="string">&quot;10.12&quot;</span>,<span class="attr">&quot;newPrice&quot;</span>:<span class="string">&quot;130.00&quot;</span>},</div><div class="line">  {<span class="attr">&quot;src&quot;</span>:<span class="string">&quot;images/detail02.jpg&quot;</span>,<span class="attr">&quot;oldPrice&quot;</span>:<span class="string">&quot;1.00&quot;</span>,<span class="attr">&quot;newPrice&quot;</span>:<span class="string">&quot;11.00&quot;</span>},</div><div class="line">]</div></pre></td></tr></table></figure>
<blockquote>
<p>JSON&#x6570;&#x636E;&#x5728;&#x4E0D;&#x540C;&#x8BED;&#x8A00;&#x8FDB;&#x884C;&#x4F20;&#x8F93;&#x65F6;&#xFF0C;&#x7C7B;&#x578B;&#x4E3A;&#x5B57;&#x7B26;&#x4E32;&#xFF0C;&#x4E0D;&#x540C;&#x7684;&#x8BED;&#x8A00;&#x5404;&#x81EA;&#x4E5F;&#x90FD;&#x5BF9;&#x5E94;&#x6709;&#x89E3;&#x6790;&#x65B9;&#x6CD5;&#xFF0C;&#x9700;&#x8981;&#x89E3;&#x6790;&#x5B8C;&#x6210;&#x540E;&#x624D;&#x80FD;&#x8BFB;&#x53D6;&#xFF1B;</p>
</blockquote>
<p><strong>PHP&#x89E3;&#x6790;&#x65B9;&#x6CD5;</strong>   </p>
<p>json_encode()&#x3001;json_decode()  </p>
<figure class="highlight php"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div></pre></td><td class="code"><pre><div class="line"><span class="meta">&lt;?php</span> </div><div class="line">    header(<span class="string">&apos;Content-Type:text/html;charset=utf-8&apos;</span>);</div><div class="line">    <span class="comment">/*&#x4EE5;json&#x683C;&#x5F0F;&#x4F20;&#x8F93;&#x6570;&#x636E;&#x7684;&#x65F6;&#x5019;&#x8981;&#x6C42;&#x54CD;&#x5E94;&#x5185;&#x5BB9;&#x683C;&#x5F0F;&#x662F; application/json*/</span></div><div class="line">    <span class="comment">/*&#x6CE8;&#x610F;&#x4E5F;&#x53EF;&#x4EE5;&#x4E0D;&#x8BBE;&#x7F6E;  &#x4F46;&#x662F;&#x8FD9;&#x9075;&#x5FAA;&#x7684;&#x4E00;&#x4E2A;&#x89C4;&#x8303;*/</span></div><div class="line">    <span class="comment">/*file_get_contents &#x83B7;&#x53D6;&#x6587;&#x4EF6;&#x5185;&#x5BB9;*/</span></div><div class="line">    $json = file_get_contents(<span class="string">&apos;01.json&apos;</span>);</div><div class="line">    <span class="comment">/*&#x8F93;&#x51FA;json&#x5185;&#x5BB9;*/</span></div><div class="line">    <span class="keyword">echo</span> $json;</div><div class="line">    <span class="keyword">echo</span> <span class="string">&apos;&lt;br&gt;&lt;br&gt;&apos;</span>;</div><div class="line">    $array = <span class="keyword">array</span>(</div><div class="line">        <span class="keyword">array</span>(<span class="string">&apos;src&apos;</span>=&gt;<span class="string">&apos;images/detail01.jpg&apos;</span>,<span class="string">&apos;newPrice&apos;</span>=&gt;<span class="string">&apos;12.00&apos;</span>,<span class="string">&apos;oldPrice&apos;</span>=&gt;<span class="string">&apos;455.00&apos;</span>),</div><div class="line">        <span class="keyword">array</span>(<span class="string">&apos;src&apos;</span>=&gt;<span class="string">&apos;images/detail02.jpg&apos;</span>,<span class="string">&apos;newPrice&apos;</span>=&gt;<span class="string">&apos;65.00&apos;</span>,<span class="string">&apos;oldPrice&apos;</span>=&gt;<span class="string">&apos;878.00&apos;</span>),</div><div class="line">        <span class="keyword">array</span>( <span class="string">&apos;src&apos;</span>=&gt;<span class="string">&apos;images/detail01.jpg&apos;</span>,<span class="string">&apos;newPrice&apos;</span>=&gt;<span class="string">&apos;100.00&apos;</span>,<span class="string">&apos;oldPrice&apos;</span>=&gt;<span class="string">&apos;1000.00&apos;</span>)</div><div class="line">    );</div><div class="line">    <span class="comment">/*&#x5C06;php&#x6570;&#x7EC4;&#x8F6C;&#x5316;&#x6210;json&#x5B57;&#x7B26;*/</span></div><div class="line">    $json_array = json_encode($array);</div><div class="line">    <span class="keyword">echo</span> $json_array;</div><div class="line">    <span class="keyword">echo</span> <span class="string">&apos;&lt;br&gt;&lt;br&gt;&apos;</span>;</div><div class="line">    <span class="comment">/*&#x5C06;json&#x5B57;&#x7B26;&#x8F6C;&#x5316;&#x6210;php&#x6570;&#x7EC4;*/</span></div><div class="line">    $array_json = json_decode($json_array);</div><div class="line">    <span class="keyword">echo</span> $array_json;</div><div class="line">    <span class="keyword">echo</span> <span class="string">&apos;&lt;br&gt;&lt;br&gt;&apos;</span>;</div><div class="line"><span class="meta">?&gt;</span></div></pre></td></tr></table></figure>
<p><strong>2&#x3001;Javascript &#x89E3;&#x6790;&#x65B9;&#x6CD5;</strong>  </p>
<ul>
<li>JSON&#x5BF9;&#x8C61;  JSON.parse()&#x3001;JSON.stringify()&#xFF1B;  </li>
<li>JSON&#x517C;&#x5BB9;&#x5904;&#x7406;json2.js  </li>
<li>&#x603B;&#x7ED3;&#xFF1A;JSON&#x4F53;&#x79EF;&#x5C0F;&#x3001;&#x89E3;&#x6790;&#x65B9;&#x4FBF;&#x4E14;&#x9AD8;&#x6548;&#xFF0C;&#x5728;&#x5B9E;&#x9645;&#x5F00;&#x53D1;&#x6210;&#x4E3A;&#x9996;&#x9009;&#x3002;</li>
</ul>
<figure class="highlight js"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div></pre></td><td class="code"><pre><div class="line"><span class="keyword">var</span> xhr = <span class="keyword">new</span> XMLHttpRequest;</div><div class="line">xhr.open(<span class="string">&apos;get&apos;</span>,<span class="string">&apos;01.php&apos;</span>);</div><div class="line">xhr.send(<span class="literal">null</span>);</div><div class="line">xhr.onreadystatechange = <span class="function"><span class="keyword">function</span>(<span class="params"></span>)</span>{</div><div class="line">  <span class="keyword">if</span>(xhr.status == <span class="number">200</span> &amp;&amp; xhr.readyState == <span class="number">4</span>){</div><div class="line">    <span class="comment">/*&#x83B7;&#x53D6;&#x4EC5;&#x4EC5;&#x662F;&#x5B57;&#x7B26;&#x4E32;*/</span></div><div class="line">    <span class="keyword">var</span> text = xhr.responseText;</div><div class="line">    <span class="comment">/*&#x9700;&#x8981;&#x628A;&#x5B57;&#x7B26;&#x4E32;&#x8F6C;&#x5316;&#x6210;JSON&#x5BF9;&#x8C61;*/</span></div><div class="line">    <span class="keyword">var</span> json_obj = <span class="built_in">JSON</span>.parse(text);</div><div class="line">    <span class="built_in">console</span>.log(json_obj);</div><div class="line">    <span class="comment">/*&#x6211;&#x4EEC;&#x4E5F;&#x53EF;&#x4EE5;&#x628A;JSON&#x5BF9;&#x8C61;&#x8F6C;&#x5316;&#x6210;&#x5B57;&#x7B26;&#x4E32;*/</span></div><div class="line">    <span class="keyword">var</span> json_str = <span class="built_in">JSON</span>.stringify(json_obj);</div><div class="line">    <span class="built_in">console</span>.log(json_str);</div><div class="line">  }</div><div class="line">}</div></pre></td></tr></table></figure>

      
    </div>

    <div>
      
        

      
    </div>

    <div>
      
        
  <div style="padding: 10px 0; margin: 20px auto; width: 90%; text-align: center;">
    <div>感谢您的支持！</div>
    <button id="rewardButton" disable="enable" onclick="var qr = document.getElementById('QR'); if (qr.style.display === 'none') {qr.style.display='block';} else {qr.style.display='none'}">
      <span>打 赏</span>
    </button>
    <div id="QR" style="display: none;">
      
        <div id="wechat" style="display: inline-block">
          <img id="wechat_qr" src="http://ofy7k3v4s.bkt.clouddn.com/wcpayCode.jpg" alt="Hongqin Ma WeChat Pay"/>
          <p>微信打赏</p>
        </div>
      
      
        <div id="alipay" style="display: inline-block">
          <img id="alipay_qr" src="http://ofy7k3v4s.bkt.clouddn.com/apayCode.jpg" alt="Hongqin Ma Alipay"/>
          <p>支付宝打赏</p>
        </div>
      
    </div>
  </div>


      
    </div>

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/tags/PHP/" rel="tag">#PHP</a>
          
        </div>
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/2015/02/19/HTML5知识体系/" rel="next" title="HTML5知识体系">
                <i class="fa fa-chevron-left"></i> HTML5知识体系
              </a>
            
          </div>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/2015/04/03/t10-gulp-构建工具/" rel="prev" title="Gulp 构建工具">
                Gulp 构建工具 <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </article>



    <div class="post-spread">
      
        <div class="ds-share flat" data-thread-key="2015/03/22/24-PHP-基础/"
     data-title="PHP-基础"
     data-content=""
     data-url="https://hongqinma.github.io/2015/03/22/24-PHP-基础/">
  <div class="ds-share-inline">
    <ul  class="ds-share-icons-16">

      <li data-toggle="ds-share-icons-more"><a class="ds-more" href="javascript:void(0);">分享到：</a></li>
      <li><a class="ds-weibo" href="javascript:void(0);" data-service="weibo">微博</a></li>
      <li><a class="ds-qzone" href="javascript:void(0);" data-service="qzone">QQ空间</a></li>
      <li><a class="ds-qqt" href="javascript:void(0);" data-service="qqt">腾讯微博</a></li>
      <li><a class="ds-wechat" href="javascript:void(0);" data-service="wechat">微信</a></li>

    </ul>
    <div class="ds-share-icons-more">
    </div>
  </div>
</div>
      
    </div>
  </div>


          </div>
          


          
  <div class="comments" id="comments">
    
      <div class="ds-thread" data-thread-key="2015/03/22/24-PHP-基础/"
           data-title="PHP-基础" data-url="https://hongqinma.github.io/2015/03/22/24-PHP-基础/">
      </div>
    
  </div>


        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap" >
            Table of Contents
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview">
            Overview
          </li>
        </ul>
      

      <section class="site-overview sidebar-panel ">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="//schema.org/Person">
          <img class="site-author-image" itemprop="image"
               src="/images/photo.jpg"
               alt="Hongqin Ma" />
          <p class="site-author-name" itemprop="name">Hongqin Ma</p>
          <p class="site-description motion-element" itemprop="description">Spell at all costs， to rush you in the future. </p>
        </div>
        <nav class="site-state motion-element">
          <div class="site-state-item site-state-posts">
            <a href="/archives">
              <span class="site-state-item-count">68</span>
              <span class="site-state-item-name">posts</span>
            </a>
          </div>

          
            <div class="site-state-item site-state-categories">
              <a href="/categories">
                <span class="site-state-item-count">16</span>
                <span class="site-state-item-name">categories</span>
              </a>
            </div>
          

          
            <div class="site-state-item site-state-tags">
              <a href="/tags">
                <span class="site-state-item-count">57</span>
                <span class="site-state-item-name">tags</span>
              </a>
            </div>
          

        </nav>

        

        <div class="links-of-author motion-element">
          
            
              <span class="links-of-author-item">
                <a href="https://github.com/HongqinMa" target="_blank" title="GitHub">
                  
                    <i class="fa fa-fw fa-github"></i>
                  
                  GitHub
                </a>
              </span>
            
              <span class="links-of-author-item">
                <a href="https://twitter.com/HongqinMa" target="_blank" title="Twitter">
                  
                    <i class="fa fa-fw fa-twitter"></i>
                  
                  Twitter
                </a>
              </span>
            
              <span class="links-of-author-item">
                <a href="https://www.facebook.com/profile.php?id=100006581058735" target="_blank" title="Facebook">
                  
                    <i class="fa fa-fw fa-facebook"></i>
                  
                  Facebook
                </a>
              </span>
            
              <span class="links-of-author-item">
                <a href="http://www.zhihu.com/people/HirakuMa" target="_blank" title="知乎">
                  
                    <i class="fa fa-fw fa-share-alt"></i>
                  
                  知乎
                </a>
              </span>
            
          
        </div>

        
        

        
        
          <div class="links-of-blogroll motion-element links-of-blogroll-inline">
            <div class="links-of-blogroll-title">
              <i class="fa  fa-fw fa-globe"></i>
              Links
            </div>
            <ul class="links-of-blogroll-list">
              
                <li class="links-of-blogroll-item">
                  <a href="http://www.cnblogs.com/rubylouvre/" title="司徒正美" target="_blank">司徒正美</a>
                </li>
              
                <li class="links-of-blogroll-item">
                  <a href="http://www.cnblogs.com/sanshi/" title="三生石上" target="_blank">三生石上</a>
                </li>
              
                <li class="links-of-blogroll-item">
                  <a href="http://www.cnblogs.com/TomXu/" title="汤姆大叔" target="_blank">汤姆大叔</a>
                </li>
              
                <li class="links-of-blogroll-item">
                  <a href="http://gold.xitu.io/" title="掘金" target="_blank">掘金</a>
                </li>
              
                <li class="links-of-blogroll-item">
                  <a href="https://segmentfault.com/" title="segmentfault" target="_blank">segmentfault</a>
                </li>
              
                <li class="links-of-blogroll-item">
                  <a href="http://www.jianshu.com/users/1cbb94e5ed4d/latest_articles" title="简书" target="_blank">简书</a>
                </li>
              
                <li class="links-of-blogroll-item">
                  <a href="https://home.cnblogs.com/" title="博客园" target="_blank">博客园</a>
                </li>
              
                <li class="links-of-blogroll-item">
                  <a href="https://www.awesomes.cn/" title="Awesomes" target="_blank">Awesomes</a>
                </li>
              
            </ul>
          </div>
        

      </section>

      
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">
            
              
            
            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#php基础"><span class="nav-number">1.</span> <span class="nav-text">php基础</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#配置-php-文件，访问-https-加密网站"><span class="nav-number">2.</span> <span class="nav-text">配置 php 文件，访问 https 加密网站</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#简单的php程序"><span class="nav-number">3.</span> <span class="nav-text">简单的php程序</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#变量"><span class="nav-number">4.</span> <span class="nav-text">变量</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#数据类型"><span class="nav-number">5.</span> <span class="nav-text">数据类型</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#运算符-amp-内容输出"><span class="nav-number">6.</span> <span class="nav-text">运算符&内容输出</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#运算符"><span class="nav-number">6.1.</span> <span class="nav-text">运算符</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#内容输出"><span class="nav-number">6.2.</span> <span class="nav-text">内容输出</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#函数"><span class="nav-number">7.</span> <span class="nav-text">函数</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#分支，循环语句"><span class="nav-number">8.</span> <span class="nav-text">分支，循环语句</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#表单处理"><span class="nav-number">9.</span> <span class="nav-text">表单处理</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#文件导入-amp-amp-常用php函数"><span class="nav-number">10.</span> <span class="nav-text">文件导入&&常用php函数</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#数据描述和例子"><span class="nav-number">11.</span> <span class="nav-text">数据描述和例子</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#xml-文件"><span class="nav-number">11.1.</span> <span class="nav-text">xml 文件</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#php-文件"><span class="nav-number">11.2.</span> <span class="nav-text">php 文件</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#JSON"><span class="nav-number">11.3.</span> <span class="nav-text">JSON</span></a></li></ol></li></ol></div>
            
          </div>
        </section>
      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright" >
  
  &copy; 
  <span itemprop="copyrightYear">2016</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">Hongqin Ma</span>
</div>

<div class="powered-by">
  Powered by <a class="theme-link" href="https://hexo.io">Hexo</a>
</div>

<div class="theme-info">
  Theme -
  <a class="theme-link" href="https://github.com/iissnan/hexo-theme-next">
    NexT.Muse
  </a>
</div>

<script async src="https://dn-lbstatics.qbox.me/busuanzi/2.3/busuanzi.pure.mini.js"></script>
<span id="busuanzi_container_site_pv">
    &nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;Page Views: <span id="busuanzi_value_site_pv"></span> 
</span>

        

<div class="busuanzi-count">

  <script async src="https://dn-lbstatics.qbox.me/busuanzi/2.3/busuanzi.pure.mini.js"></script>

  
    <span class="site-uv"><i class="fa fa-user"></i><span class="busuanzi-value" id="busuanzi_value_site_uv"></span></span>
  

  
    <span class="site-pv"><i class="fa fa-eye"></i><span class="busuanzi-value" id="busuanzi_value_site_pv"></span></span>
  
  
</div>



        
      </div>
    </footer>

    <div class="back-to-top">
      <i class="fa fa-arrow-up"></i>
    </div>
  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  



  
  <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>

  
  <script type="text/javascript" src="/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>

  
  <script type="text/javascript" src="/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.0.2"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.0.2"></script>



  
  

  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=5.0.2"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.0.2"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.0.2"></script>



  

  
    
  

  <script type="text/javascript">
    var duoshuoQuery = {short_name:"Hiraku"};
    (function() {
      var ds = document.createElement('script');
      ds.type = 'text/javascript';ds.async = true;
      ds.id = 'duoshuo-script';
      ds.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') + '//static.duoshuo.com/embed.js';
      ds.charset = 'UTF-8';
      (document.getElementsByTagName('head')[0]
      || document.getElementsByTagName('body')[0]).appendChild(ds);
    })();
  </script>

  
    
    <script src="/lib/ua-parser-js/dist/ua-parser.min.js?v=0.7.9"></script>
    <script src="/js/src/hook-duoshuo.js"></script>
  






  
  

  

  

  
  <script src="https://cdn1.lncld.net/static/js/av-core-mini-0.6.1.js"></script>
  <script>AV.initialize("PPmoIQxeu8Sd21h6Tl9TthNx-gzGzoHsz", "rTvbY2H7DvWzRipiBwn72RQ4");</script>
  <script>
    function showTime(Counter) {
      var query = new AV.Query(Counter);
      var entries = [];
      var $visitors = $(".leancloud_visitors");

      $visitors.each(function () {
        entries.push( $(this).attr("id").trim() );
      });

      query.containedIn('url', entries);
      query.find()
        .done(function (results) {
          var COUNT_CONTAINER_REF = '.leancloud-visitors-count';

          if (results.length === 0) {
            $visitors.find(COUNT_CONTAINER_REF).text(0);
            return;
          }

          for (var i = 0; i < results.length; i++) {
            var item = results[i];
            var url = item.get('url');
            var time = item.get('time');
            var element = document.getElementById(url);

            $(element).find(COUNT_CONTAINER_REF).text(time);
          }
          for(var i = 0; i < entries.length; i++) {
            var url = entries[i];
            var element = document.getElementById(url);
            var countSpan = $(element).find(COUNT_CONTAINER_REF);
            if( countSpan.text() == '') {
              countSpan.text(0);
            }
          }
        })
        .fail(function (object, error) {
          console.log("Error: " + error.code + " " + error.message);
        });
    }

    function addCount(Counter) {
      var $visitors = $(".leancloud_visitors");
      var url = $visitors.attr('id').trim();
      var title = $visitors.attr('data-flag-title').trim();
      var query = new AV.Query(Counter);

      query.equalTo("url", url);
      query.find({
        success: function(results) {
          if (results.length > 0) {
            var counter = results[0];
            counter.fetchWhenSave(true);
            counter.increment("time");
            counter.save(null, {
              success: function(counter) {
                var $element = $(document.getElementById(url));
                $element.find('.leancloud-visitors-count').text(counter.get('time'));
              },
              error: function(counter, error) {
                console.log('Failed to save Visitor num, with error message: ' + error.message);
              }
            });
          } else {
            var newcounter = new Counter();
            /* Set ACL */
            var acl = new AV.ACL();
            acl.setPublicReadAccess(true);
            acl.setPublicWriteAccess(true);
            newcounter.setACL(acl);
            /* End Set ACL */
            newcounter.set("title", title);
            newcounter.set("url", url);
            newcounter.set("time", 1);
            newcounter.save(null, {
              success: function(newcounter) {
                var $element = $(document.getElementById(url));
                $element.find('.leancloud-visitors-count').text(newcounter.get('time'));
              },
              error: function(newcounter, error) {
                console.log('Failed to create');
              }
            });
          }
        },
        error: function(error) {
          console.log('Error:' + error.code + " " + error.message);
        }
      });
    }

    $(function() {
      var Counter = AV.Object.extend("Counter");
      if ($('.leancloud_visitors').length == 1) {
        addCount(Counter);
      } else if ($('.post-title-link').length > 1) {
        showTime(Counter);
      }
    });
  </script>



  

  

  
  
  <!-- custom analytics part create by xiamo -->
<script src="https://cdn1.lncld.net/static/js/av-core-mini-0.6.1.js"></script>
<script>AV.initialize("PPmoIQxeu8Sd21h6Tl9TthNx-gzGzoHsz", "rTvbY2H7DvWzRipiBwn72RQ4");</script>
<script>
function showTime(Counter) {
  var query = new AV.Query(Counter);
  $(".leancloud_visitors").each(function() {
    var url = $(this).attr("id").trim();
    query.equalTo("url", url);
    query.find({
      success: function(results) {
        if (results.length == 0) {
          var content = '0 ' + $(document.getElementById(url)).text();
          $(document.getElementById(url)).text(content);
          return;
        }
        for (var i = 0; i < results.length; i++) {
          var object = results[i];
          var content = object.get('time') + ' ' + $(document.getElementById(url)).text();
          $(document.getElementById(url)).text(content);
        }
      },
      error: function(object, error) {
        console.log("Error: " + error.code + " " + error.message);
      }
    });

  });
}

function addCount(Counter) {
  var Counter = AV.Object.extend("Counter");
  url = $(".leancloud_visitors").attr('id').trim();
  title = $(".leancloud_visitors").attr('data-flag-title').trim();
  var query = new AV.Query(Counter);
  query.equalTo("url", url);
  query.find({
    success: function(results) {
      if (results.length > 0) {
        var counter = results[0];
        counter.fetchWhenSave(true);
        counter.increment("time");
        counter.save(null, {
          success: function(counter) {
            var content =  counter.get('time') + ' ' + $(document.getElementById(url)).text();
            $(document.getElementById(url)).text(content);
          },
          error: function(counter, error) {
            console.log('Failed to save Visitor num, with error message: ' + error.message);
          }
        });
      } else {
        var newcounter = new Counter();
        newcounter.set("title", title);
        newcounter.set("url", url);
        newcounter.set("time", 1);
        newcounter.save(null, {
          success: function(newcounter) {
              console.log("newcounter.get('time')="+newcounter.get('time'));
            var content = newcounter.get('time') + ' ' + $(document.getElementById(url)).text();
            $(document.getElementById(url)).text(content);
          },
          error: function(newcounter, error) {
            console.log('Failed to create');
          }
        });
      }
    },
    error: function(error) {
      console.log('Error:' + error.code + " " + error.message);
    }
  });
}
$(function() {
  var Counter = AV.Object.extend("Counter");
  if ($('.leancloud_visitors').length == 1) {
    addCount(Counter);
  } else if ($('.post-title-link').length > 1) {
    showTime(Counter);
  }
}); 
</script>

  
</body>
</html>
